```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Netty ByteBuf 内存管理深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-title {
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #f8f8f8;
            border-left: 4px solid #4FD1C5;
            color: #2D3748;
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .highlight-box {
            border-left: 4px solid #4FD1C5;
            background: rgba(79, 209, 197, 0.1);
        }
        .nav-link {
            position: relative;
        }
        .nav-link:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 2px;
            background: #4FD1C5;
            transition: width 0.3s;
        }
        .nav-link:hover:after {
            width: 100%;
        }
        .mermaid-tooltip {
            display: none;
            position: absolute;
            background: white;
            padding: 10px;
            border-radius: 4px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            z-index: 100;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="relative bg-gradient-to-r from-blue-500 to-teal-500 text-white py-20 px-4 md:px-10">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-2/3 pr-10">
                    <h1 class="hero-title text-4xl md:text-5xl font-bold mb-4">Netty ByteBuf 内存管理</h1>
                    <p class="text-xl mb-8 opacity-90">高性能网络编程中的数据存储与缓冲核心组件</p>
                    <div class="flex space-x-4">
                        <a href="#overview" class="bg-white text-teal-600 hover:bg-gray-100 px-6 py-3 rounded-md font-medium transition duration-300 shadow-md">开始探索</a>
                        <a href="#diagram" class="bg-transparent border-2 border-white hover:bg-white hover:text-teal-600 px-6 py-3 rounded-md font-medium transition duration-300">查看图解</a>
                    </div>
                </div>
                <div class="hidden md:block md:w-1/3 mt-10 md:mt-0">
                    <img src="https://images.unsplash.com/photo-1558494949-ef010cbdcc31?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Network Data Flow" class="rounded-lg shadow-xl transform rotate-3">
                </div>
            </div>
        </div>
    </div>

    <!-- Navigation -->
    <div class="bg-white shadow-sm sticky top-0 z-10">
        <div class="max-w-6xl mx-auto px-4">
            <div class="flex justify-between items-center py-4">
                <div class="text-xl font-bold text-teal-600">ByteBuf 解析</div>
                <div class="hidden md:flex space-x-8">
                    <a href="#overview" class="nav-link text-gray-700 hover:text-teal-600 py-2">概述</a>
                    <a href="#memory" class="nav-link text-gray-700 hover:text-teal-600 py-2">内存管理</a>
                    <a href="#allocation" class="nav-link text-gray-700 hover:text-teal-600 py-2">内存分配</a>
                    <a href="#performance" class="nav-link text-gray-700 hover:text-teal-600 py-2">性能优化</a>
                </div>
                <button class="md:hidden text-gray-600">
                    <i class="fas fa-bars text-2xl"></i>
                </button>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-4 py-12">
        <!-- Overview Section -->
        <section id="overview" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-teal-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-info-circle text-teal-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">1. ByteBuf 的基本概述</h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="md:col-span-2">
                    <p class="text-lg text-gray-700 mb-6">
                        <span class="text-4xl float-left mr-2 font-serif leading-none text-teal-600">N</span>
                        etty 中的 <code class="bg-gray-100 px-1 py-0.5 rounded">ByteBuf</code> 是处理字节数据的核心类，用于存储数据、读取和写入字节流。它提供了与传统 <code class="bg-gray-100 px-1 py-0.5 rounded">ByteBuffer</code> 类似的功能，但在性能和灵活性上有所优化。<code class="bg-gray-100 px-1 py-0.5 rounded">ByteBuf</code> 通过内存池化的方式管理内存，减少了频繁的内存分配和垃圾回收。
                    </p>
                    
                    <div class="highlight-box p-6 mb-8 rounded-r">
                        <h3 class="font-bold text-xl mb-3 text-teal-700">核心特点</h3>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-teal-500 mt-1 mr-2"></i>
                                <span>支持内存池化，减少 GC 压力</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-teal-500 mt-1 mr-2"></i>
                                <span>灵活的读写指针管理</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-teal-500 mt-1 mr-2"></i>
                                <span>支持堆内存和直接内存两种模式</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-teal-500 mt-1 mr-2"></i>
                                <span>引用计数机制防止内存泄漏</span>
                            </li>
                        </ul>
                    </div>
                </div>
                
                <div class="md:col-span-1">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                        <div class="bg-teal-600 text-white px-4 py-3">
                            <h3 class="font-semibold text-lg">代码示例</h3>
                        </div>
                        <div class="code-block p-4 overflow-x-auto">
                            <pre><code class="language-java">public interface ByteBuf extends 
    ReferenceCounted, Comparable&lt;ByteBuf&gt; {
    // 返回 ByteBuf 的容量
    int capacity();
    
    // 返回当前可读字节数
    int readableBytes();
    
    // 读取一个字节
    byte readByte();
    
    // 写入一个字节
    ByteBuf writeByte(int value);
    
    // 获取底层数据
    byte[] array();
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-10">
                <h3 class="text-2xl font-bold mb-4 text-gray-800">执行流程</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-teal-600 text-3xl mb-4">
                            <i class="fas fa-project-diagram"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">1. 接口抽象</h4>
                        <p class="text-gray-600">ByteBuf 是一个抽象接口，不同的实现类（如 PooledByteBuf、UnpooledByteBuf）提供了具体的内存管理方式。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-teal-600 text-3xl mb-4">
                            <i class="fas fa-ruler-combined"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">2. 容量查询</h4>
                        <p class="text-gray-600">使用 capacity() 方法获取 ByteBuf 的容量，readableBytes() 方法返回当前可读取的字节数。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-teal-600 text-3xl mb-4">
                            <i class="fas fa-exchange-alt"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">3. 数据操作</h4>
                        <p class="text-gray-600">readByte() 和 writeByte() 用于操作数据，支持多种数据类型的读写。</p>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Memory Management Section -->
        <section id="memory" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-memory text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">2. ByteBuf 的内存管理策略</h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="md:col-span-2">
                    <p class="text-lg text-gray-700 mb-6">
                        Netty 中的 <code class="bg-gray-100 px-1 py-0.5 rounded">ByteBuf</code> 使用内存池化机制（<code class="bg-gray-100 px-1 py-0.5 rounded">PooledByteBufAllocator</code>）来管理内存，这意味着内存块的分配和释放不是每次都直接操作堆内存，而是通过内存池来进行复用。这种方式有效减少了内存分配的开销，降低了 GC 压力。
                    </p>
                    
                    <div class="bg-blue-50 border-l-4 border-blue-500 p-6 mb-8 rounded-r">
                        <h3 class="font-bold text-xl mb-3 text-blue-700">内存池优势</h3>
                        <div class="grid grid-cols-2 gap-4">
                            <div>
                                <div class="font-medium mb-1"><i class="fas fa-bolt text-blue-500 mr-2"></i>性能提升</div>
                                <p class="text-sm text-gray-600">减少频繁的内存分配和释放操作</p>
                            </div>
                            <div>
                                <div class="font-medium mb-1"><i class="fas fa-shield-alt text-blue-500 mr-2"></i>稳定性</div>
                                <p class="text-sm text-gray-600">避免内存碎片化，提高系统稳定性</p>
                            </div>
                            <div>
                                <div class="font-medium mb-1"><i class="fas fa-tachometer-alt text-blue-500 mr-2"></i>高效利用</div>
                                <p class="text-sm text-gray-600">重复利用内存块，提高内存使用率</p>
                            </div>
                            <div>
                                <div class="font-medium mb-1"><i class="fas fa-leaf text-blue-500 mr-2"></i>GC友好</div>
                                <p class="text-sm text-gray-600">显著降低垃圾回收频率和开销</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="md:col-span-1">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                        <div class="bg-blue-600 text-white px-4 py-3">
                            <h3 class="font-semibold text-lg">内存池实现</h3>
                        </div>
                        <div class="code-block p-4 overflow-x-auto">
                            <pre><code class="language-java">public class PooledByteBufAllocator 
    implements ByteBufAllocator {
    private final PoolThreadCache threadCache;
    private final PoolArena&lt;byte[]&gt; heapArena;
    private final PoolArena&lt;ByteBuffer&gt; directArena;

    public ByteBuf allocate(PooledByteBufAllocator parent) {
        PoolThreadCache cache = threadCache.get();
        ByteBuf buf = heapArena.allocate(cache);
        if (buf != null) return buf;
        return directArena.allocate(cache);
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-10">
                <h3 class="text-2xl font-bold mb-4 text-gray-800">执行流程</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-blue-600 text-3xl mb-4">
                            <i class="fas fa-boxes"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">1. 分配器初始化</h4>
                        <p class="text-gray-600">PooledByteBufAllocator 管理堆内存池和直接内存池。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-blue-600 text-3xl mb-4">
                            <i class="fas fa-user-clock"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">2. 线程缓存</h4>
                        <p class="text-gray-600">首先尝试从当前线程的缓存池 threadCache 中获取内存。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-blue-600 text-3xl mb-4">
                            <i class="fas fa-database"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">3. 内存分配</h4>
                        <p class="text-gray-600">如果缓存不足，从堆内存池 heapArena 或直接内存池 directArena 分配。</p>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Diagram Section -->
        <section id="diagram" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-project-diagram text-purple-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">ByteBuf 内存管理流程图</h2>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md">
                <div class="mermaid">
                    graph TD
                        A[创建ByteBuf请求] --> B{是否有线程缓存?}
                        B -->|是| C[从线程缓存分配]
                        B -->|否| D{堆内存是否足够?}
                        D -->|是| E[从堆内存池分配]
                        D -->|否| F[从直接内存池分配]
                        C --> G[返回ByteBuf]
                        E --> G
                        F --> G
                        G --> H[使用ByteBuf]
                        H --> I{引用计数为0?}
                        I -->|是| J[归还内存到池]
                        I -->|否| H
                </div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-6 mt-8">
                <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <h4 class="font-bold text-lg mb-2">内存层次</h4>
                    <p class="text-gray-600">Netty采用多级内存分配策略，优先使用线程本地缓存，其次是堆内存，最后是直接内存。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-recycle"></i>
                    </div>
                    <h4 class="font-bold text-lg mb-2">回收机制</h4>
                    <p class="text-gray-600">通过引用计数控制内存回收，引用为0时自动归还内存池，实现内存复用。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-balance-scale"></i>
                    </div>
                    <h4 class="font-bold text-lg mb-2">负载均衡</h4>
                    <p class="text-gray-600">智能在堆内存和直接内存之间平衡分配，避免单一内存类型耗尽。</p>
                </div>
            </div>
        </section>
        
        <!-- Memory Allocation Section -->
        <section id="allocation" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-orange-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-archive text-orange-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">3. ByteBuf 的内存分配</h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="md:col-span-2">
                    <p class="text-lg text-gray-700 mb-6">
                        <code class="bg-gray-100 px-1 py-0.5 rounded">ByteBuf</code> 的内存分配有两种方式：堆内存（Heap Memory）和直接内存（Direct Memory）。堆内存是基于 JVM 堆的，而直接内存则是通过 <code class="bg-gray-100 px-1 py-0.5 rounded">java.nio.ByteBuffer</code> 直接操作的内存。
                    </p>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
                        <div class="bg-orange-50 p-6 rounded-lg border-l-4 border-orange-500">
                            <h4 class="font-bold text-lg mb-3 text-orange-700">堆内存</h4>
                            <ul class="space-y-2 text-gray-700">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-orange-500 mt-1 mr-2"></i>
                                    <span>分配在JVM堆上</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-orange-500 mt-1 mr-2"></i>
                                    <span>GC管理生命周期</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-orange-500 mt-1 mr-2"></i>
                                    <span>访问速度较快</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-orange-500 mt-1 mr-2"></i>
                                    <span>适合小数据量</span>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-indigo-50 p-6 rounded-lg border-l-4 border-indigo-500">
                            <h4 class="font-bold text-lg mb-3 text-indigo-700">直接内存</h4>
                            <ul class="space-y-2 text-gray-700">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-indigo-500 mt-1 mr-2"></i>
                                    <span>分配在JVM堆外</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-indigo-500 mt-1 mr-2"></i>
                                    <span>手动管理内存</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-indigo-500 mt-1 mr-2"></i>
                                    <span>减少一次内存拷贝</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-indigo-500 mt-1 mr-2"></i>
                                    <span>适合大数据量I/O</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                
                <div class="md:col-span-1">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                        <div class="bg-gradient-to-r from-orange-500 to-indigo-600 text-white px-4 py-3">
                            <h3 class="font-semibold text-lg">分配代码示例</h3>
                        </div>
                        <div class="code-block p-4 overflow-x-auto">
                            <pre><code class="language-java">public class PooledByteBuf&lt;T&gt; extends AbstractByteBuf {
    // 直接内存分配
    public ByteBuffer allocateDirect(int capacity) {
        return ByteBuffer.allocateDirect(capacity);
    }
    
    // 堆内存分配
    public byte[] allocateHeap(int capacity) {
        return new byte[capacity];
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-10">
                <h3 class="text-2xl font-bold mb-4 text-gray-800">执行流程</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-orange-600 text-3xl mb-4">
                            <i class="fas fa-layer-group"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">1. 堆内存分配</h4>
                        <p class="text-gray-600">ByteBuf 直接使用 byte[] 数组来存储数据，由JVM管理内存。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-indigo-600 text-3xl mb-4">
                            <i class="fas fa-memory"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">2. 直接内存分配</h4>
                        <p class="text-gray-600">使用 ByteBuffer.allocateDirect 来分配堆外内存，提升I/O性能。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm card-hover">
                        <div class="text-teal-600 text-3xl mb-4">
                            <i class="fas fa-chess-board"></i>
                        </div>
                        <h4 class="font-bold text-lg mb-2">3. 池化管理</h4>
                        <p class="text-gray-600">无论哪种内存，都通过内存池统一管理，提高内存使用效率。</p>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Performance Section -->
        <section id="performance" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-tachometer-alt text-green-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">4. ByteBuf 的性能优化</h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="md:col-span-2">
                    <p class="text-lg text-gray-700 mb-6">
                        Netty 在设计 <code class="bg-gray-100 px-1 py-0.5 rounded">ByteBuf</code> 时非常注重性能，尤其是内存的分配与回收。通过内存池化、引用计数、零拷贝等技术，Netty 能够在高并发场景下保持优异的性能。
                    </p>
                    
                    <div class="bg-green-50 border-l-4 border-green-500 p-6 mb-8 rounded-r">
                        <h3 class="font-bold text-xl mb-4 text-green-700">关键技术</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div>
                                <div class="font-bold mb-2 flex items-center">
                                    <i class="fas fa-water mr-2 text-green-500"></i>
                                    <span>内存池化</span>
                                </div>
                                <p class="text-sm text-gray-600">重用内存块，减少分配/释放开销</p>
                            </div>
                            <div>
                                <div class="font-bold mb-2 flex items-center">
                                    <i class="fas fa-hashtag mr-2 text-green-500"></i>
                                    <span>引用计数</span>
                                </div>
                                <p class="text-sm text-gray-600">精准控制内存生命周期</p>
                            </div>
                            <div>
                                <div class="font-bold mb-2 flex items-center">
                                    <i class="fas fa-copy mr-2 text-green-500"></i>
                                    <span>零拷贝</span>
                                </div>
                                <p class="text-sm text-gray-600">减少数据拷贝次数</p>
                            </div>
                            <div>
                                <div class="font-bold mb-2 flex items-center">
                                    <i class="fas fa-users mr-2 text-green-500"></i>
                                    <span>线程本地缓存</span>
                                </div>
                                <p class="text-sm text-gray-600">减少线程竞争</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="md:col-span-1">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                        <div class="bg-green-600 text-white px-4 py-3">
                            <h3 class="font-semibold text-lg">零拷贝示例</h3>
                        </div>
                        <div class="code-block p-4 overflow-x-auto">
                            <pre><code class="language-java">// 零拷贝优化示例
public class ZeroCopyHandler {
    public void sendFile(ChannelHandlerContext ctx, File file) {
        try {
            FileChannel fileChannel = 
                new RandomAccessFile(file, "r").getChannel();
            ctx.writeAndFlush(new DefaultFileRegion(
                fileChannel, 0, fileChannel.size()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-10">
                <h3 class="text-2xl font-bold mb-4 text-gray-800">性能提升效果</h3>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="mermaid">
                        barChart
                            title 性能对比(单位: 毫秒)
                            x-axis 操作
                            y-axis 时间
                            series "堆内存"
                            series "直接内存"
                            series "内存池"
                            series "零拷贝"
                            series "传统方式"
                            Data: 分配/释放 50 35 20 15 80
                            Data: 读写操作 40 30 25 10 60
                            Data: 文件传输 45 25 20 8 75
                    </div>
                </div>
            </div>
        </section>
    </div>
    
    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">分享前沿技术，传播开发知识</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-teal-400 hover:text-teal-300 transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        <span>访问我们的语雀知识库</span>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>
    
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeVariables: {
                primaryColor: '#E2F3F2',
                primaryTextColor: '#2D3748',
                primaryBorderColor: '#4FD1C5',
                lineColor: '#CBD5E0',
                secondaryColor: '#F7FAFC',
                tertiaryColor: '#E2E8F0'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```